home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
RLaB 1.18c
/
testmatrix
/
dorr.r
< prev
next >
Wrap
Text File
|
1994-12-20
|
2KB
|
61 lines
//-------------------------------------------------------------------//
// Synopsis: Dorr matrix - diagonally dominant, ill-conditioned,
// tridiagonal.
// Syntax: DL = dorr ( N , THETA )
// Description:
// dorr(N, THETA) returns a list containing the vectors defining
// a row diagonally dominant, tridiagonal M-matrix that is
// ill-conditioned for small values of the parameter THETA >= 0.
// The columns of INV(C) vary greatly in norm. THETA defaults to
// 0.01. The amount of diagonal dominance is given by (ignoring
// rounding errors):
// COMP(C)*ONES(N,1) = THETA*(N+1)^2 * [1,0,0,... 0,1]'.
// Reference:
// F.W. Dorr, An example of ill-conditioning in the numerical
// solution of singular perturbation problems, Math. Comp., 25 (1971),
// pp. 271-283.
// This file is a translation of dorr.m from version 2.0 of
// "The Test Matrix Toolbox for Matlab", described in Numerical
// Analysis Report No. 237, December 1993, by N. J. Higham.
//-------------------------------------------------------------------//
dorr = function ( n , theta )
{
local (n, theta)
if (!exist (theta)) { theta = 0.01; }
c = zeros(n,1);
e = c;
d = c;
// All length n for convenience. Make c, e of length n-1 later.
h = 1/(n+1);
m = floor( (n+1)/2 );
term = theta/h^2;
i = (1:m)';
c[i] = -term*ones(m,1);
e[i] = c[i] - (0.5-i*h)/h;
d[i] = -(c[i] + e[i]);
i = (m+1:n)';
e[i] = -term*ones(n-m,1);
c[i] = e[i] + (0.5-i*h)/h;
d[i] = -(c[i] + e[i]);
c = c[2:n];
e = e[1:n-1];
return << c = c; d = d; e = e >>;
};